﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AP.Framework.Infrastructure.Entities;
using AP.Framework.Infrastructure.Database;
using AP.Framework.Infrastructure.Repositories;

namespace ApCMS.Models
{
    public class LayoutModels
    {
        public IEnumerable<cms_ProductCategory> ProductCategoryList { get; set; }
        public IEnumerable<cms_Article> ArticleList { get; set; }
        public cms_Contact contact { get; set; }
        public LayoutModels()
        {
            ApContext context = new ApContext();
            ProductCategoryRepository productCategoryRepository = new ProductCategoryRepository(context);
            ArticleRepository articleRepository = new ArticleRepository(context);
            LinkRepository linksRepository = new LinkRepository(context);
            ContactRepository contactRepository = new ContactRepository(context);
            ProductCategoryList = productCategoryRepository.GetAll();
            ArticleList = articleRepository.GetAll().OrderByDescending(p => p.CreateTime);
            contact = contactRepository.GetAll().FirstOrDefault();

        }
    }

}